@extends('layouts.system')

@section('css')
    <style>
        .modal-backdrop {
            z-index: 1030;
        }
    </style>
@endsection

@section('content')
    <div id="cl-wrapper" class="fixed-menu">
        <div class="container-fluid" id="pcont">
            <div class="col-md-12" style="padding-right: 0;">
                <div class="block-flat">
                    <div class="header">
                        <div class="pull-left">
                            <p class="jb_underline">企业申请</p>
                        </div>
                        <div class="clearfix"></div>
                    </div>
                    <div class="content">
                        <div class="table-responsive">
                            <div>
                                <table class="table table-bordered" id="datatable-icons">
                                    <thead style="background-color: #ffd866;">
                                    <tr>
                                        <th>ID</th>
                                        <th>企业名称</th>
                                        <th>联系人</th>
                                        <th>联系方式</th>
                                        <th>营业执照</th>
                                        <th>任务类型偏向</th>
                                        <th>目标群体偏向</th>
                                        <th style="width: 200px">备注信息</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr v-for="item in lists">
                                        <td><span v-text="item.id"></span></td>
                                        <td><span v-bind:title="item.company_name" v-text="item.company_name"></span></td>
                                        <td><span v-bind:title="item.contact_man" v-text="item.contact_man"></span></td>
                                        <td><span v-bind:title="item.contact_way" v-text="item.contact_way"></span></td>
                                        <td>
                                            <a data-toggle="lightbox" v-bind:href="'#Lightbox_' + item.id ">
                                                查看
                                            </a>
                                            <div v-bind:id=" 'Lightbox_' + item.id " class="lightbox fade"  tabindex="100000" role="dialog" aria-hidden="true">
                                                <div class='lightbox-dialog'>
                                                    <div class='lightbox-content'>
                                                        <img v-bind:src="item.business_license">
                                                    </div>
                                                </div>
                                            </div>
                                        </td>
                                        <td><span v-bind:title="item.release_type" v-text="item.release_type"></span></td>
                                        <td><span v-bind:title="item.target_throng" v-text="item.target_throng"></span></td>
                                        <td><span v-bind:title="item.remark" v-text="item.remark"></span></td>
                                        <td>
                                            <a v-bind:href="'/admin/company/show/' + item.id ">详情</a>
                                            <a href="javascript:;" v-on:click="del(item.id)">删除</a>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('script')
    <script type="text/javascript">

      Vue.use(VueResource)
      var vm = new Vue({
        el: '#pcont',
        data: {
          lists: {}
        },
        created: function () {
          getLists(this);
        },
        methods : {
            del: function (id) {
                if (confirm('是否删除该企业申请？')) {
                    del(this,id)
                }
          }
        }
      })

      function getLists(_vm) {
        _vm.$http.get('/admin/company/getLists')
          .then(function (response) {
            var json = response.body;
            if (json.state == 1) {
              _vm._data.lists = json.data
            }
          })
          .catch(function (response) {
            console.log(response)
          })
      }

      function del(_vm,id) {
          _vm.$http.post("/admin/company/delete/" + id, {}, {headers: header()})
              .then(function (response) {
                  var json = response.body;
                  if (json.state == 1) {
                      getLists(_vm)
                      alert(json.msg)
                  }
              }).catch(function (response) {
              console.log(response)
          })
      }

    </script>
@endsection